package com.coincalf.admin.web.ucenter;


import com.baomidou.mybatisplus.plugins.Page;
import com.coincalf.admin.annotation.Log;
import com.coincalf.admin.common.ResultMap;
import com.coincalf.admin.dto.UserWalletDTO;
import com.coincalf.admin.enums.SysLogTypeEnum;
import com.coincalf.admin.service.UserWalletService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户提币表 前端控制器
 * </p>
 *
 * @author lxl
 * @since 2018-05-19
 */
@RestController
@RequestMapping("/userWallet")
@Api(value = "用户提币controller", tags = { "用户提币" })
public class UserWalletController {

    @Autowired
    private UserWalletService userWalletService;

    @Log(value = "查询用户的提币地址",type = SysLogTypeEnum.SELECT)
    @PreAuthorize("hasAuthority('user_wallet_query')")
    @GetMapping
    @ApiImplicitParams({
            @ApiImplicitParam(name = "size", value = "每页显示条数，默认 10", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "current", value = "当前页", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "String", paramType = "query")

    })
    @ApiOperation(authorizations = {@Authorization(value="Authorization")},value = "用户的提币地址" ,httpMethod = "GET")
    @RequestMapping(method = RequestMethod.GET,value = "selectPage")
    @ApiResponses({

            @ApiResponse(code =0,message = "成功",response=UserWalletDTO.class),
            @ApiResponse(code =1,message = "失败")

    })
    public ResultMap selectUserWalletList(int size,int current,Long userId){
        if(size==0||current==0){
            size=10;
            current=1;
        }
        Page<UserWalletDTO> page=new Page<UserWalletDTO>(current,size);

        if(userId==null){
            return ResultMap.getFailureResult("用户id不能为空！");
        }
        return ResultMap.getSuccessfulResult(userWalletService.selectUserWalletList(page, userId));
    }

}

